class Employee {
    private name: string;
    private department: string;
    private salary: number;
    private subordinates: Employee[];
    public constructor(name: string, department: string, salary: number) {
        this.name = name;
        this.department = department;
        this.salary = salary;
        this.subordinates = [];
    }
    public add(employee: Employee): void {
        this.subordinates.push(employee);
    }
    public remove(employee: Employee): void {
        this.subordinates.splice(this.subordinates.indexOf(employee), 1);
    }
    public getSubordinates(): Employee[] {
        return this.subordinates;
    }
}

function showEmployees(employee: Employee): void {
    console.log(employee);
    for (const subordinate of employee.getSubordinates()) {
        showEmployees(subordinate);
    }
}

function main() {
    const CEO: Employee = new Employee("John Doe", "CEO", 50000);
    const headSales: Employee = new Employee("Jane Smith", "Head Sales", 40000);
    const headMarketing: Employee = new Employee("Mark Johnson", "Head Marketing", 30000);
    const clerk1: Employee = new Employee("Tom Johnson", "Marketing", 25000);
    const clerk2: Employee = new Employee("David Lee", "Marketing", 25000);
    const sales1: Employee = new Employee("Sarah Lee", "Sales", 20000);
    const sales2: Employee = new Employee("Mike Lee", "Sales", 20000);
    CEO.add(headSales);
    CEO.add(headMarketing);
    headSales.add(sales1);
    headSales.add(sales2);
    headMarketing.add(clerk1);
    headMarketing.add(clerk2);
    showEmployees(CEO);
}

main();
